export default function debounce(fn: Function, delay=500) {
  let timer: string | number | NodeJS.Timeout | undefined
  return function(this: any, ...args: any[]) {
    clearTimeout(timer)
    timer = setTimeout(() => {
      fn.apply(this, ...args)
    }, delay)
  }
}